package com.yj.rocketmq.api.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yj.core.base.BaseModel;
import com.yj.rocketmq.producer.dto.MessageDTO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.Date;
import java.util.UUID;

/**
 * @author
 */
@Setter
@Getter
@ToString
@NoArgsConstructor
@TableName(value = "T_Mq_MessageRecord")
public class MessageRecord extends BaseModel {

    /**
     * 消息id
     */
    @TableId(type = IdType.INPUT)
    private String msgId;

    /**
     * topic
     */
    private String topic;

    /**
     * tag
     */
    private String tag;

    /**
     * 消息内容
     */
    private String body;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 修改时间
     */
    private Date updateTime;

    public MessageRecord(MessageDTO messageDTO) {
        this.msgId = UUID.randomUUID().toString();
        this.topic = messageDTO.getTopic();
        this.tag = messageDTO.getTag();
        this.body = messageDTO.getBody();
    }
}